<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useCommonStore } from '@/stores/common';
import { useRouter, useData } from 'vitepress';
import OButton from '@/components/OButton.vue';

import searchError from '@/assets/search-error.png';
import searchErrorDark from '@/assets/search-error-dark.png';

const useCommon = useCommonStore();
const router = useRouter();
const { t } = useI18n();
const data = useData();
const isDark = computed(() => (useCommon.theme === 'light' ? true : false));

const goPath = (path: string) => {
  router.go(`/${data.lang.value + path}`);
};
</script>

<template>
  <div class="page404">
    <img :src="isDark ? searchError : searchErrorDark" alt="" />
    <p class="text">404</p>
    <o-button type="primary" @click="goPath('/home/')">
      {{ t('back_home') }}
    </o-button>
  </div>
</template>

<style lang="scss">
.page404 {
  width: 50%;
  margin: 0 auto;
  padding: 64px 0;
  text-align: center;
  min-height: calc(100vh - 80px - 240px);
  img {
    width: 50%;
  }
  .text {
    font-size: 14px;
    color: var(--theme-text);
    margin: 12px 0 24px;
  }
}
</style>
